<?php


abstract class BaseSolicitud extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $cp_solicitud;


	
	protected $cf_estudiante;


	
	protected $cf_beneficio;


	
	protected $cf_trabajador;


	
	protected $fecha;


	
	protected $motivo;


	
	protected $decision;


	
	protected $fecha_decision;


	
	protected $entrevista;


	
	protected $estatus;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getCpSolicitud()
	{

		return $this->cp_solicitud;
	}

	
	public function getCfEstudiante()
	{

		return $this->cf_estudiante;
	}

	
	public function getCfBeneficio()
	{

		return $this->cf_beneficio;
	}

	
	public function getCfTrabajador()
	{

		return $this->cf_trabajador;
	}

	
	public function getFecha($format = 'Y-m-d')
	{

		if ($this->fecha === null || $this->fecha === '') {
			return null;
		} elseif (!is_int($this->fecha)) {
						$ts = strtotime($this->fecha);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse value of [fecha] as date/time value: " . var_export($this->fecha, true));
			}
		} else {
			$ts = $this->fecha;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	
	public function getMotivo()
	{

		return $this->motivo;
	}

	
	public function getDecision()
	{

		return $this->decision;
	}

	
	public function getFechaDecision($format = 'Y-m-d')
	{

		if ($this->fecha_decision === null || $this->fecha_decision === '') {
			return null;
		} elseif (!is_int($this->fecha_decision)) {
						$ts = strtotime($this->fecha_decision);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse value of [fecha_decision] as date/time value: " . var_export($this->fecha_decision, true));
			}
		} else {
			$ts = $this->fecha_decision;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	
	public function getEntrevista()
	{

		return $this->entrevista;
	}

	
	public function getEstatus()
	{

		return $this->estatus;
	}

	
	public function setCpSolicitud($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->cp_solicitud !== $v) {
			$this->cp_solicitud = $v;
			$this->modifiedColumns[] = SolicitudPeer::CP_SOLICITUD;
		}

	} 
	
	public function setCfEstudiante($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->cf_estudiante !== $v) {
			$this->cf_estudiante = $v;
			$this->modifiedColumns[] = SolicitudPeer::CF_ESTUDIANTE;
		}

	} 
	
	public function setCfBeneficio($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->cf_beneficio !== $v) {
			$this->cf_beneficio = $v;
			$this->modifiedColumns[] = SolicitudPeer::CF_BENEFICIO;
		}

	} 
	
	public function setCfTrabajador($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->cf_trabajador !== $v) {
			$this->cf_trabajador = $v;
			$this->modifiedColumns[] = SolicitudPeer::CF_TRABAJADOR;
		}

	} 
	
	public function setFecha($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse date/time value for [fecha] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->fecha !== $ts) {
			$this->fecha = $ts;
			$this->modifiedColumns[] = SolicitudPeer::FECHA;
		}

	} 
	
	public function setMotivo($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->motivo !== $v) {
			$this->motivo = $v;
			$this->modifiedColumns[] = SolicitudPeer::MOTIVO;
		}

	} 
	
	public function setDecision($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->decision !== $v) {
			$this->decision = $v;
			$this->modifiedColumns[] = SolicitudPeer::DECISION;
		}

	} 
	
	public function setFechaDecision($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse date/time value for [fecha_decision] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->fecha_decision !== $ts) {
			$this->fecha_decision = $ts;
			$this->modifiedColumns[] = SolicitudPeer::FECHA_DECISION;
		}

	} 
	
	public function setEntrevista($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->entrevista !== $v) {
			$this->entrevista = $v;
			$this->modifiedColumns[] = SolicitudPeer::ENTREVISTA;
		}

	} 
	
	public function setEstatus($v)
	{

						if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->estatus !== $v) {
			$this->estatus = $v;
			$this->modifiedColumns[] = SolicitudPeer::ESTATUS;
		}

	} 
	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->cp_solicitud = $rs->getString($startcol + 0);

			$this->cf_estudiante = $rs->getString($startcol + 1);

			$this->cf_beneficio = $rs->getString($startcol + 2);

			$this->cf_trabajador = $rs->getString($startcol + 3);

			$this->fecha = $rs->getDate($startcol + 4, null);

			$this->motivo = $rs->getString($startcol + 5);

			$this->decision = $rs->getString($startcol + 6);

			$this->fecha_decision = $rs->getDate($startcol + 7, null);

			$this->entrevista = $rs->getString($startcol + 8);

			$this->estatus = $rs->getString($startcol + 9);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 10; 
		} catch (Exception $e) {
			throw new PropelException("Error populating Solicitud object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(SolicitudPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			SolicitudPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(SolicitudPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = SolicitudPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setCpSolicitud($pk);  
					$this->setNew(false);
				} else {
					$affectedRows += SolicitudPeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


			if (($retval = SolicitudPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}



			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = SolicitudPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getCpSolicitud();
				break;
			case 1:
				return $this->getCfEstudiante();
				break;
			case 2:
				return $this->getCfBeneficio();
				break;
			case 3:
				return $this->getCfTrabajador();
				break;
			case 4:
				return $this->getFecha();
				break;
			case 5:
				return $this->getMotivo();
				break;
			case 6:
				return $this->getDecision();
				break;
			case 7:
				return $this->getFechaDecision();
				break;
			case 8:
				return $this->getEntrevista();
				break;
			case 9:
				return $this->getEstatus();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = SolicitudPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getCpSolicitud(),
			$keys[1] => $this->getCfEstudiante(),
			$keys[2] => $this->getCfBeneficio(),
			$keys[3] => $this->getCfTrabajador(),
			$keys[4] => $this->getFecha(),
			$keys[5] => $this->getMotivo(),
			$keys[6] => $this->getDecision(),
			$keys[7] => $this->getFechaDecision(),
			$keys[8] => $this->getEntrevista(),
			$keys[9] => $this->getEstatus(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = SolicitudPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setCpSolicitud($value);
				break;
			case 1:
				$this->setCfEstudiante($value);
				break;
			case 2:
				$this->setCfBeneficio($value);
				break;
			case 3:
				$this->setCfTrabajador($value);
				break;
			case 4:
				$this->setFecha($value);
				break;
			case 5:
				$this->setMotivo($value);
				break;
			case 6:
				$this->setDecision($value);
				break;
			case 7:
				$this->setFechaDecision($value);
				break;
			case 8:
				$this->setEntrevista($value);
				break;
			case 9:
				$this->setEstatus($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = SolicitudPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setCpSolicitud($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setCfEstudiante($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setCfBeneficio($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setCfTrabajador($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setFecha($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setMotivo($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setDecision($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setFechaDecision($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setEntrevista($arr[$keys[8]]);
		if (array_key_exists($keys[9], $arr)) $this->setEstatus($arr[$keys[9]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(SolicitudPeer::DATABASE_NAME);

		if ($this->isColumnModified(SolicitudPeer::CP_SOLICITUD)) $criteria->add(SolicitudPeer::CP_SOLICITUD, $this->cp_solicitud);
		if ($this->isColumnModified(SolicitudPeer::CF_ESTUDIANTE)) $criteria->add(SolicitudPeer::CF_ESTUDIANTE, $this->cf_estudiante);
		if ($this->isColumnModified(SolicitudPeer::CF_BENEFICIO)) $criteria->add(SolicitudPeer::CF_BENEFICIO, $this->cf_beneficio);
		if ($this->isColumnModified(SolicitudPeer::CF_TRABAJADOR)) $criteria->add(SolicitudPeer::CF_TRABAJADOR, $this->cf_trabajador);
		if ($this->isColumnModified(SolicitudPeer::FECHA)) $criteria->add(SolicitudPeer::FECHA, $this->fecha);
		if ($this->isColumnModified(SolicitudPeer::MOTIVO)) $criteria->add(SolicitudPeer::MOTIVO, $this->motivo);
		if ($this->isColumnModified(SolicitudPeer::DECISION)) $criteria->add(SolicitudPeer::DECISION, $this->decision);
		if ($this->isColumnModified(SolicitudPeer::FECHA_DECISION)) $criteria->add(SolicitudPeer::FECHA_DECISION, $this->fecha_decision);
		if ($this->isColumnModified(SolicitudPeer::ENTREVISTA)) $criteria->add(SolicitudPeer::ENTREVISTA, $this->entrevista);
		if ($this->isColumnModified(SolicitudPeer::ESTATUS)) $criteria->add(SolicitudPeer::ESTATUS, $this->estatus);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(SolicitudPeer::DATABASE_NAME);

		$criteria->add(SolicitudPeer::CP_SOLICITUD, $this->cp_solicitud);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getCpSolicitud();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setCpSolicitud($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setCfEstudiante($this->cf_estudiante);

		$copyObj->setCfBeneficio($this->cf_beneficio);

		$copyObj->setCfTrabajador($this->cf_trabajador);

		$copyObj->setFecha($this->fecha);

		$copyObj->setMotivo($this->motivo);

		$copyObj->setDecision($this->decision);

		$copyObj->setFechaDecision($this->fecha_decision);

		$copyObj->setEntrevista($this->entrevista);

		$copyObj->setEstatus($this->estatus);


		$copyObj->setNew(true);

		$copyObj->setCpSolicitud(NULL); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new SolicitudPeer();
		}
		return self::$peer;
	}

} 